import { createReducer } from '../utils';
import { LOGOUT_USER_SUCCESS, LOGOUT_USER_REQUEST } from '../contants/index';

const initialState = {
    session:null,
    isLogouted: false,
    isLogouting: false,
    statusText: null
};

export default createReducer(initialState, {    
    [LOGOUT_USER_REQUEST]: (state, payload) => {
        return Object.assign({},state, {
            'isLogouting': true,
            'isLogouted': false,
            'statusText': '正在退出...'
        });
    },
    [LOGOUT_USER_SUCCESS]: (state, payload) => {
        return Object.assign({}, state, {
            'isLogouted': true,
            'isLogouting': false,
            'session' :payload.session,
            'statusText': '您已成功退出登录'
        });
    } 
})